package cn.ggcms.cms.dao.impl;

import java.util.List;

import cn.ggcms.cms.dao.AdminUserDao;
import cn.ggcms.cms.utils.SimpleDao;
import cn.ggcms.cms.vo.AdminUser;

public class AdminUserImpl extends SimpleDao<AdminUser> implements AdminUserDao {

	public boolean doInsertAdminUser(AdminUser adminUser) {
		boolean flag = false;
		try {
			 super.save(adminUser);
			flag = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}
	public AdminUser findAdminUser(AdminUser adminUser) {
		String hql= "from AdminUser as u where u.userName=? and u.password=? ";
		List<AdminUser> list = super.find(hql,new Object[]{adminUser.getUserName(),adminUser.getPassword()});
		return list.size()>0?list.get(0):null;
	}
	public AdminUser findAdminUserById(int id) {
		return (AdminUser) super.find(AdminUser.class,id);
	}
	public List<AdminUser> findAdminUsers() {

		return super.setMaxResults(0).find(AdminUser.class);
	}
	public boolean doDeleteAdminUserById(int id) {
		boolean flag = false;
		try {
			super.delete(AdminUser.class, id);
			flag = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
		
		
	}
	public boolean doUpdateAdminUser(AdminUser adminUser) {
		boolean flag=false;
		try {
			super.update(adminUser);
			flag=true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}

	
}
